package com.irdstudio.efp.esb.api.service.common.repository;

import com.irdstudio.efp.console.service.facade.PrdInfoService;
import com.irdstudio.efp.console.service.vo.PrdInfoVO;
import com.irdstudio.efp.console.service.vo.PrdInfoVOBuilder;
import com.irdstudio.efp.esb.api.bean.psd.apply.req.PsdApproveReqBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

import java.util.Optional;

/**
 * 需求编号:2019D08--
 * 问题编号:
 * 开发人员: caoxin
 * 创建日期:2019/12/3
 * 功能描述:
 * 修改日期:2019/12/3
 * 修改描述:
 */
@Service("prdRepository")
public class PrdRepository {

    @Autowired
    @Qualifier("prdInfoService")
    private PrdInfoService prdInfoService;

    public PrdInfoVO getProduct(String prdId) {
        return Optional.ofNullable(prdInfoService.queryLastPrdInfo(PrdInfoVOBuilder.aPrdInfoVO().withPrdCode(prdId).build())).orElseGet(PrdInfoVO::new);
    }
}
